// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using NSQL.Generator;
using NSQL.Resource;
using NSQL.Statements;

namespace NSQL.Extensions
{
    public static class SqlServerGeneratorExtensions
    {
        public static string ToSqlServer(this IStatement statement, Action<SqlGeneratorSettings> setupAction)
        {
            var settings = SqlServerGenerator.DefaultSettings;
            setupAction(settings);
            return new SqlServerGenerator(settings).Generate(statement);
        }
        
        public static string ToSqlServer(this IStatement statement, SqlGeneratorSettings settings)
        {
            return new SqlServerGenerator(settings ?? new SqlGeneratorSettings()).Generate(statement);
        }

        public static string ToSqlServer(this IStatement statement)
        {
            return SqlServerGenerator.Instance.Generate(statement);
        }

        public static string ToSqlServer(this IStatement statement, IDatabaseInfo databaseInfo)
        {
            return new SqlServerGenerator(new SqlGeneratorSettings
            {
                Database = databaseInfo
            }).Generate(statement);
        }
    }
}